﻿Imports Phila
Imports Phila.Sql
Imports Phila.CommonClasses
Imports Telerik.WebControls

Public Class ViewTours
    Inherits System.Web.UI.Page
    Public Shared clsActive As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub

    Protected Sub bindGridView(ByVal radGrid As Telerik.WebControls.RadGrid, ByVal Type As String, Optional ByVal catId As String = Nothing)
        Dim strSql As String
        'strSql = "select t.*, c.Name CatName from tours t inner join category c on c.id=t.CategoryId where IsPackage=1 order by ViewOrder, Name"
        If Type = "cruise" Then
            Type = "IsCruise"
            clsActive = "active"
        ElseIf Type = "safari" Then
            Type = "IsSafari"
        ElseIf Type = "short" Then
            Type = "IsShortBreak"
        Else
            Type = "IsPackage"
        End If
        strSql = "select * from ptn_Tours where " & Type & "=1"
        Fill_Grid(radGrid, strSql)
        'Fill_Grid(radGrid, strSql)
    End Sub

    Private Sub radGrid_DeleteCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles radGrid.DeleteCommand
        Dim ID As String = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ID").ToString
        lblMsg.Text = ID.ToString()
        lblMsg.ForeColor = Drawing.Color.DarkRed
        lblError.ForeColor = Drawing.Color.DarkCyan
        Try
            Insert_Update_Delete_Record("delete from ptn_tours where id=" & ID)
        Catch ex As Exception
            lblMsg.Text = "Unable to Delete Record. Reason: " + ex.Message
            lblMsg.ForeColor = Drawing.Color.Red
            e.Canceled = True
        End Try
    End Sub

    Protected Sub radGrid_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles radGrid.NeedDataSource
        If Not LCase(Request.QueryString("type")) Is Nothing Then
            bindGridView(radGrid, LCase(Request.QueryString("type")))
        Else
            bindGridView(radGrid, "IsPackage")
        End If
        'Fill_Grid(radGridPackage, "select t.*, c.Name CatName from tours t inner join category c on c.id=t.CategoryId where IsPackage=1 order by ViewOrder, Name")
    End Sub
End Class